#!/bin/sh

. `dirname $0`/eval_tools.sh

TRAPHANDLE_LOGFILE=${SNMP_TMPDIR_REMOTE}/traphandle.log

# "inline" trap handler
if [ "x$2" = "xtraphandle" ]; then
  cat - >>$TRAPHANDLE_LOGFILE
  exit 0
fi

HEADER snmptrapd traphandle: launching external shell script

SKIPIF DISABLE_SNMPV2C

#
# Begin test
#

snmp_version=v2c
TESTCOMMUNITY=testcommunity

CONFIGTRAPD authcommunity execute $TESTCOMMUNITY
CONFIGTRAPD doNotLogTraps true
CONFIGTRAPD traphandle default SNMP_TMPDIR_REMOTE=${SNMP_TMPDIR_REMOTE} $0 $1 traphandle

STARTTRAPD

CAPTURE "snmptrap -d -Ci -$snmp_version -c $TESTCOMMUNITY $SNMP_TRANSPORT_SPEC:$SNMP_TEST_DEST$SNMP_SNMPTRAPD_PORT 0 .1.3.6.1.6.3.1.1.5.1 system.sysContact.0 s handled_trap_$snmp_version"
DELAY
CHECKFILE $TRAPHANDLE_LOGFILE "handled_trap_$snmp_version"

STOPTRAPD

FINISHED
